<template>
    <div>
        <h1>修改页面</h1>
        <table>
            <thead>
                <tr>
                    <td>房号id</td>
                    <td>
                        <input type="text"  v-model="data.FhId" disabled>
                    </td>
                </tr>
                <tr>
                    <td>房型名称</td>
                    <td>
                        <input type="text" v-model="data.FXname" >
                    </td>
                </tr>
                <tr>
                    <td>房号金额</td>
                    <td>
                        <input type="text"  v-model="data.Jine" >
                    </td>
                </tr>
                <tr>
                    <td>房号数量</td>
                    <td>
                        <input type="text"  v-model="data.Houscount">
                    </td>
                </tr>
                <tr>
                    <td>房号名称</td>
                    <td>
                        <input type="checkbox" v-model="data.FHname" :value="110">110
                        <input type="checkbox" v-model="data.FHname" :value="120">120
                        <input type="checkbox" v-model="data.FHname" :value="130">130
                        <input type="checkbox" v-model="data.FHname" :value="140">140
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="radio" v-model="data.zhuangtai" name="sex" :value="1">开启
                        <input type="radio" v-model="data.zhuangtai" name="sex" :value="2">停用
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="更新" @click="Geng" >
                    </td>
                </tr>
            </thead>
        </table>
    </div>
    <a href="/">显示列表</a>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';
//实例化
const router=useRouter();
const route=useRoute();
const data=ref({
  "FhId": 0,
  "FXname": "string",
  "Jine": 0,
  "Houscount": 0,
  "FHname": "string",
  "zhuangtai": 0,
  "IsDelete": true,
  "fwj": 0
});
onMounted(()=>{
    fantian();
})


const fantian=()=>{
    var vid=route.query.id;
    axios.get("https://localhost:7276/api/Fh/Fantian",{params:{id:vid}}).then(res=>{
        data.value=res.data;
    })
}
const Geng=()=>{
    if(data.value.FXname=="")
    {
        alert("房间名称不能为空")
        return;
    }
    data.value.FHname="110,120,130,140";
    axios.put("https://localhost:7276/api/Fh/UpdateFh",data.value).then(res=>{
        data.value.FHname="110";
        if(res.data>0)
        {
            alert("更新成功");
            location.href="/";
        }
        else
        {
            alert("更新失败")
        }
    })
}













</script>

<style scoped>

</style>